-
Notifications
You must be signed in to change notification settings - Fork 542
Add attribution button gravity, position normally #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ins to behave similarly to ios
…avity and it cant be tested now
…nt and adjust it to density
…verlayButtonFixes
This continues the work of PR #615 to fix #261 and #540, and replaces the changed calculation of #681 with a more general solution. The underlying issue here is that the attribution button is left-aligned by default on Android, and right-aligned by default on iOS. The approach taken in #681 where the margin x value is assumed to represent the left margin does not generalize to iOS, where it will be a right margin. Since the alignment / gravity of the button can be configured on each platform, we can address this problem at its source by exposing this configuration through flutter-mapbox-gl. Then on Android, we can apply the button margins same way the compass is positioned, with respect to its gravity. I've tested this on iOS and Android with both bottom left and bottom right attribution buttons. The best option currently is to configure the attribution button to bottom right, where it falls by default on iOS. In this way you will have a similar experience on both platforms with a fully configurable margin. The mapbox logo's alignment/position is also configurable, should anyone want to expose it in future.
felix-ht
reviewed
Nov 2, 2021
android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/mapbox/mapboxgl/MapboxMapBuilder.java
Outdated
Show resolved
Hide resolved
When setting the position of the compass and attribution button, we need to assume the platform default gravity for those elements if no explicit value has been provided. An incorrect default was assumed for the attribution button (copied from the compass), so that is corrected here. The methods for setting gravity do not require a default since they are only called if an explicit gravity value has been provided. Those default cases are removed here. #731 (comment)
This name is not commonly used outside of android. Also, we're converting to the typed position objects as quickly as possible with these changes, rather than passing around the int. #731 (comment)
felix-ht
approved these changes
Nov 3, 2021
Collaborator
felix-ht
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
n8han
added a commit
that referenced
this pull request
Nov 8, 2021
When setting the position of the compass and attribution button, we need to assume the platform default gravity for those elements if no explicit value has been provided. An incorrect default was assumed for the attribution button (copied from the compass), so that is corrected here. The methods for setting gravity do not require a default since they are only called if an explicit gravity value has been provided. Those default cases are removed here. #731 (comment)
n8han
added a commit
that referenced
this pull request
Nov 8, 2021
This name is not commonly used outside of android. Also, we're converting to the typed position objects as quickly as possible with these changes, rather than passing around the int. #731 (comment)
Closed
m0nac0
pushed a commit
to maplibre/flutter-maplibre-gl
that referenced
this pull request
Nov 19, 2021
* fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios * fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now * feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density * Add attribution button gravity, position normally This continues the work of PR #615 to fix #261 and #540, and replaces the changed calculation of #681 with a more general solution. The underlying issue here is that the attribution button is left-aligned by default on Android, and right-aligned by default on iOS. The approach taken in #681 where the margin x value is assumed to represent the left margin does not generalize to iOS, where it will be a right margin. Since the alignment / gravity of the button can be configured on each platform, we can address this problem at its source by exposing this configuration through flutter-mapbox-gl. Then on Android, we can apply the button margins same way the compass is positioned, with respect to its gravity. I've tested this on iOS and Android with both bottom left and bottom right attribution buttons. The best option currently is to configure the attribution button to bottom right, where it falls by default on iOS. In this way you will have a similar experience on both platforms with a fully configurable margin. The mapbox logo's alignment/position is also configurable, should anyone want to expose it in future. * Improve switch default behavior When setting the position of the compass and attribution button, we need to assume the platform default gravity for those elements if no explicit value has been provided. An incorrect default was assumed for the attribution button (copied from the compass), so that is corrected here. The methods for setting gravity do not require a default since they are only called if an explicit gravity value has been provided. Those default cases are removed here. flutter-mapbox-gl/maps#731 (comment) * Rename "gravity" methods in web implementation This name is not commonly used outside of android. Also, we're converting to the typed position objects as quickly as possible with these changes, rather than passing around the int. flutter-mapbox-gl/maps#731 (comment) Co-authored-by: Ching Yaw Hao <[email protected]> (cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767)
m0nac0
added a commit
to maplibre/flutter-maplibre-gl
that referenced
this pull request
Nov 19, 2021
…eam#731) (#50) * Add attribution button gravity, position normally (#731) * fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios * fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now * feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density * Add attribution button gravity, position normally This continues the work of PR #615 to fix #261 and #540, and replaces the changed calculation of #681 with a more general solution. The underlying issue here is that the attribution button is left-aligned by default on Android, and right-aligned by default on iOS. The approach taken in #681 where the margin x value is assumed to represent the left margin does not generalize to iOS, where it will be a right margin. Since the alignment / gravity of the button can be configured on each platform, we can address this problem at its source by exposing this configuration through flutter-mapbox-gl. Then on Android, we can apply the button margins same way the compass is positioned, with respect to its gravity. I've tested this on iOS and Android with both bottom left and bottom right attribution buttons. The best option currently is to configure the attribution button to bottom right, where it falls by default on iOS. In this way you will have a similar experience on both platforms with a fully configurable margin. The mapbox logo's alignment/position is also configurable, should anyone want to expose it in future. * Improve switch default behavior When setting the position of the compass and attribution button, we need to assume the platform default gravity for those elements if no explicit value has been provided. An incorrect default was assumed for the attribution button (copied from the compass), so that is corrected here. The methods for setting gravity do not require a default since they are only called if an explicit gravity value has been provided. Those default cases are removed here. flutter-mapbox-gl/maps#731 (comment) * Rename "gravity" methods in web implementation This name is not commonly used outside of android. Also, we're converting to the typed position objects as quickly as possible with these changes, rather than passing around the int. flutter-mapbox-gl/maps#731 (comment) Co-authored-by: Ching Yaw Hao <[email protected]> (cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767) * Fix formatting Co-authored-by: Nathan <[email protected]>
github-actions bot
pushed a commit
to maplibre/flutter-maplibre-gl
that referenced
this pull request
Nov 19, 2021
…(upstream#731) (#50) * Add attribution button gravity, position normally (#731) * fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios * fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now * feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density * Add attribution button gravity, position normally This continues the work of PR #615 to fix #261 and #540, and replaces the changed calculation of #681 with a more general solution. The underlying issue here is that the attribution button is left-aligned by default on Android, and right-aligned by default on iOS. The approach taken in #681 where the margin x value is assumed to represent the left margin does not generalize to iOS, where it will be a right margin. Since the alignment / gravity of the button can be configured on each platform, we can address this problem at its source by exposing this configuration through flutter-mapbox-gl. Then on Android, we can apply the button margins same way the compass is positioned, with respect to its gravity. I've tested this on iOS and Android with both bottom left and bottom right attribution buttons. The best option currently is to configure the attribution button to bottom right, where it falls by default on iOS. In this way you will have a similar experience on both platforms with a fully configurable margin. The mapbox logo's alignment/position is also configurable, should anyone want to expose it in future. * Improve switch default behavior When setting the position of the compass and attribution button, we need to assume the platform default gravity for those elements if no explicit value has been provided. An incorrect default was assumed for the attribution button (copied from the compass), so that is corrected here. The methods for setting gravity do not require a default since they are only called if an explicit gravity value has been provided. Those default cases are removed here. flutter-mapbox-gl/maps#731 (comment) * Rename gravity methods in web implementation This name is not commonly used outside of android. Also, we're converting to the typed position objects as quickly as possible with these changes, rather than passing around the int. flutter-mapbox-gl/maps#731 (comment) Co-authored-by: Ching Yaw Hao <[email protected]> (cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767) * Fix formatting Co-authored-by: Nathan <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This continues the work of PR #615 and closes #261, closes #540, and replaces
the changed calculation of #681 with a more general solution.
The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.
Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.
I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.
The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.